package com.wwy.hkapi.HKApi;

import com.wwy.hkapi.HKApi.init.HkInit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;


/**
 * 海康设备退出
 * @Author: wwy
 * @Date: 2020/8/4 10:44
 */
public class HkLogout {
    private static final Logger LOGGER = LoggerFactory.getLogger(HkLogout.class);

    /**
     * 海康设备退出
     * @param lUserID
     */
    public static void hkLogout(int lUserID){
        boolean b = HkInit.hCNetSDK.NET_DVR_Logout(lUserID);
        if(b){
            LOGGER.info("退出成功，用户id:{}",lUserID);
            String key = "";
            //删除全局集合中的数据
            for (Map.Entry<String, Integer> stringIntegerEntry : HkLogin.lUserIDMap.entrySet()) {
                key = stringIntegerEntry.getKey();
                Integer value = stringIntegerEntry.getValue();
                if(lUserID == value){
                    break;
                }
            }
            HkLogin.lUserIDMap.remove(key);
            HkLogin.userInfoMap.remove(key);
            HkLogin.deviceInfoMap.remove(key);
        }else{
            LOGGER.info("退出失败，用户id:{}",lUserID);
        }
    }
}
